﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 引用类型参数    // 当值类型的参数要想达到引用类型参数的效果，使用引用传递，使用ref关键字修饰形式参数和实际参数
{
    class Program
    {
        static void Main(string[] args)
        {
            MyMath mm = new MyMath();
            int myScore = 60;
            int yourScore = 100;
            // ref修饰的变量在传递参数以前一定要赋值
            mm.Swap(ref myScore, ref yourScore);
            Console.WriteLine(myScore);
            Console.WriteLine(yourScore);
        }
    }

    class MyMath
    {
        public void Swap(ref int x, ref int y)
        {
            int temp = x;
            x = y;
            y = temp;
        }
    }
}
